package ch.exploadingelephants.model;

import java.util.Iterator;

/**
 * @author Sandro De Zanet
 * 
 */
public class GridIterator<T> implements Iterator<T> {

    private final Grid<T> grid;
    private final int position;
    private final int numberOfPosition;

    /**
     * @param grid
     */
    public GridIterator(Grid<T> grid) {
	this.grid = grid;
	position = 0;
	numberOfPosition = grid.getHeight() * grid.getWidth();
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.util.Iterator#hasNext()
     */
    public boolean hasNext() {
	return position < numberOfPosition;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.util.Iterator#next()
     */
    public T next() {
	return grid.get(position / numberOfPosition, position
		% numberOfPosition);
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.util.Iterator#remove()
     */
    public void remove() {

    }

}
